<template>
  <!-- 导航组件 -->
  <div class="rich-show">
     <div 
      class="edit_container" 
      v-html="ruleFormLocal.content || ruleFormLocal.placehoder"
      :style="{background: ruleFormLocal.bgColor,color: ruleFormLocal.colorText}"
    >
        
      </div>
     <option-right v-if="dateFactory.activeBorder">
      <div class="option-wrap">
        <el-form :model="ruleFormLocal"   label-width="100px">
          <div class="edit-componet-title">
            商品搜索
          </div>
          <el-form-item label="背景颜色" prop="bgColor">
            <div class="border-wrap">
              <el-color-picker v-model="ruleFormLocal.bgColor" size="small" ></el-color-picker>
              <el-link type="primary" :underline="false" @click="ruleFormLocal.bgColor == '#fff'">重置</el-link>
            </div>
          </el-form-item>
          <el-form-item label="字体颜色" prop="bgColor">
            <div class="border-wrap">
              <el-color-picker v-model="ruleFormLocal.colorText" size="small" ></el-color-picker>
              <el-link type="primary" :underline="false" @click="ruleFormLocal.colorText == '#fff'">重置</el-link>
            </div>
          </el-form-item>
          <el-form-item label="框体样式" prop="borderInputRadius">
             <quill-editor v-model="ruleFormLocal.content"
              ref="myQuillEditor"
              :options="editorOption"
              @blur="onEditorBlur($event)"
              @focus="onEditorFocus($event)"
              @ready="onEditorReady($event)">
            </quill-editor>
          </el-form-item>
          
        </el-form>
       
      </div>
    </option-right>
  </div>
</template>

<script>
export default {
  name: 'NavBar',
  props: {
    dateFactory: Object,
    index: Number,
    diyData: Array,
  },
  data() {
    return {
      editorOption: {

      },
      ruleFormLocal:this.dateFactory.ruleForm,
    }
  }, 
  computed: {
    editor() {
      return this.$refs.myQuillEditor.quill
    }
  },
  watch: {
    ruleFormLocal: {
      handler: function (newValue) {
        this.diyData[this.index].ruleForm = newValue
        if (this.ruleFormLocal.page == 'AboutWe') {
           this.$EventBus.$emit('diyFactoryAboutMe', this.diyData)
        } else if (this.ruleFormLocal.page == 'CurriculumSchedule') {
            this.$EventBus.$emit('diyFactoryCurriShe', this.diyData)
        } else if (this.ruleFormLocal.page == 'Home') {
           this.$EventBus.$emit('diyFactory', this.diyData)
        }else if (this.ruleFormLocal.page == 'ArticleDetail') {
           this.$EventBus.$emit('diyFactoryArticleDetail', this.diyData)
        }else if (this.ruleFormLocal.page == 'MyPage') {
           this.$EventBus.$emit('diyFactoryMyPage', this.diyData)
        }
      },
      deep: true,
    }
  },
  computed: {
    
  },
  mounted() {
    
  },
  methods: {
    onEditorBlur(quill) {
      console.log('editor blur!', quill)
    },
    onEditorFocus(quill) {
      console.log('editor focus!', quill)
    },
    onEditorReady(quill) {
      console.log('editor ready!', quill)
    },
    onEditorChange({ quill, html, text }) {
      console.log('editor change!', quill, html, text)
      this.content = html
    }
  },
}
</script>

<style lang="less" scoped>
  .edit_container {
    width: 100%;
    height: auto;
    padding: 10px;
    box-sizing: border-box;
    word-break: break-all;
    img {
      width: 100%;
    }
  }
  .option-wrap {
    .el-form  {
      .edit-componet-title {
        margin-bottom: 15px;
        padding-bottom: 7px;
        border-bottom: 1px solid #e5e5e5;
        font-size: 14px;
      }
      .el-form-item {
        .border-wrap {
          display: flex;
          align-items: center;
          .el-color-picker {
            margin-right: 12px;
          }
        }
        .side {
          display: flex;
          align-items: center;
          align-items: center;
          .el-slider {
            flex: 1;
          }
          &> span {
            margin-left: 14px;
          }
        }
      }
    }
  }
  // 导航样式
  .nav-wrap {
    display: flex;
    align-items: center;
    height: 48px;
    color: #fff;
    width: 100%;
    background: #66c93a;
  }
  .nav-wrap .nav {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
</style>